<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<script type="text/javascript" src="./jquery.min.js"></script>
<body>
<button id="url">URL</button>
<h3 class="showURL">localhost</h3>
<div>
    <h2>signup:post</h2>
    <p>usernick:<input type="text" name="usernick" id="usernick"></p>
    <p>username:<input type="text" name="username" id="username"></p>
    <p>userpassword:<input type="text" name="userpassword" id="userpassword"></p>
    <p>userphone:<input type="text" name="userphone" id="userphone"></p>
    <p>userbuildnumber:<input type="text" name="userbuildnumber" id="userbuildnumber"></p>
    <p>userbedroomnumber:<input type="text" name="userbedroomnumber" id="userbedroomnumber"></p>
    <p>userintroduce:<input type="text" name="userintroduce" id="userintroduce"></p>
    <button id="signup">signup</button>
</div>
<div>
    <h2>login:post</h2>
    <p>username:<input type="text" name="Lusername" id="Lusername"></p>
    <p>userpassword:<input type="text" name="Luserpassword" id="Luserpassword"></p>
    <button id="login">login</button>
</div>
<div>
    <h2>createOrder:post</h2>
    <p>tasktype:<input type="text" name="tasktype" id="tasktype">####类型 0带外卖 1带饭菜</p>
    <p>taskintegral:<input type="text" name="taskintegral" id="taskintegral">####支付积分 </p>
    <p>taskdescribe:<input type="text" name="taskdescribe" id="taskdescribe">####描述 （不要辣）</p>
    <p>tasktime:<input type="text" name="tasktime" id="tasktime">(可不)####默认30分</p>
    <p>taskstartplace:<input type="text" name="taskstartplace" id="taskstartplace">(可不)####默认注册账号所在门口</p>
    <p>taskendbuildingplace:<input type="text" name="taskendbuildingplace" id="taskendbuildingplace">(可不)默认注册账号所在</p>
    <p>taskendroomplace:<input type="text" name="taskendroomplace" id="taskendroomplace">(可不)默认注册账号所在</p>
    <button id="createOrder">createOrder</button>
</div>
<div>
    <h2>allUnfinishOrder:get####没被接单的任务</h2>
    <button id="allUnfinishOrder">allUnfinishOrder</button>
</div>
<div>
    <h2>acceptOrder:post</h2>
    <p>id:<input type="text" name="_id" id="_id">####订单属性</p>
    <button id="acceptOrder">acceptOrder</button>
</div>
<div>
    <h2>myOrder:get####接受或发布的订单（未分完成未完成）</h2>
    <button id="myOrder">myOrder</button>
</div>
<div>
    <h2>myUnfinishOrder:get####接受或发布的订单（未完成）</h2>
    <button id="myUnfinishOrder">myUnfinishOrder</button>
</div>
<div>
    <h2>completeOrder:post####确定完成订单</h2>
    <p>id:<input type="text" name="_id" id="_id">####订单属性</p>
    <button id="completeOrder">completeOrder</button>
</div>
<script>
    var url='localhost';
        var urlp=1;
        $("#url").on('click',function(){
                if(urlp==0){
                    url='localhost';
                    urlp=1;
                    $(".showURL").html(url);
                    console.log(url);
                }else {
                    url='123.206.107.125';
                    urlp=0;
                    $(".showURL").html(url);
                     console.log(url);
                }

        });
    $("#signup").on('click',function(){
    var user={};
    user.usernick=$("#usernick").val();
    user.username=$("#username").val();
    user.userpassword=$("#userpassword").val();
    user.userphone=$("#userphone").val();
    user.userbuildnumber=$("#userbuildnumber").val();
    user.userbedroomnumber=$("#userbedroomnumber").val();
    user.userintroduce=$("#userintroduce").val();
     $.ajax({
        type: "post",
        url: "http://"+url+":3333/signup", 
        data: user,
        dataType:"json",
        async:false,
        cache:false,
        timeout:10,
        success: function(data){
            console.log(data);
        },
        error: function(data){
            console.log(data);
        }
    });
    });
        $("#login").on('click',function(){
    var user={};
    user.username=$("#Lusername").val();
    user.userpassword=$("#Luserpassword").val();
     $.ajax({
        type: "post",
        url: "http://"+url+":3333/login", 
        data: user,
        dataType:"json",
        async:false,
        cache:false,
        timeout:10,
        success: function(data){
            console.log(data);
        },
        error: function(data){
            console.log(data);
        }
    });
    });
    $("#createOrder").on('click',function(){
        var task={};
        task.tasktype=$('#tasktype').val();
        task.tasktime=$('#tasktime').val();
        task.taskintegral=$('#taskintegral').val();
        task.taskdescribe=$('#taskdescribe').val();
        task.taskstartplace=$('#taskstartplace').val();
        task.taskendbuildingplace=$('#taskendbuildingplace').val();
        task.taskendroomplace=$('#taskendroomplace').val();
         $.ajax({
            type: "post",
            url: "http://"+url+":3333/createOrder", 
            data: task,
            dataType:"json",
            async:false,
            cache:false,
            timeout:10,
            success: function(data){
                console.log(data);
            },
            error: function(data){
                console.log(data);
            }
        });
    });
    $("#allUnfinishOrder").on('click',function(){
         $.ajax({
            type: "get",
            url: "http://"+url+":3333/allUnfinishOrder", 
            dataType:"json",
            async:false,
            cache:false,
            timeout:10,
            success: function(data){
                console.log(data);
            },
            error: function(data){
                console.log(data);
            }
        });
    });
    $("#acceptOrder").on('click',function(){
        var ac={};
        ac.id=$("#_id").val();
     $.ajax({
        type: "post",
        url: "http://"+url+":3333/acceptOrder", 
        data: ac,
        dataType:"json",
        async:false,
        cache:false,
        timeout:10,
        success: function(data){
            console.log(data);
        },
        error: function(data){
            console.log(data);
        }
    });
    });
    $("#myOrder").on('click',function(){
         $.ajax({
            type: "get",
            url: "http://"+url+":3333/myOrder", 
            dataType:"json",
            async:false,
            cache:false,
            timeout:10,
            success: function(data){
                console.log(data);
            },
            error: function(data){
                console.log(data);
            }
        });
    });
    $("#myUnfinishOrder").on('click',function(){
         $.ajax({
            type: "get",
            url: "http://"+url+":3333/myUnfinishOrder", 
            dataType:"json",
            async:false,
            cache:false,
            timeout:10,
            success: function(data){
                console.log(data);
            },
            error: function(data){
                console.log(data);
            }
        });
    });
     $("#completeOrder").on('click',function(){
        var ac={};
        ac.id=$("#_id").val();
     $.ajax({
        type: "post",
        url: "http://"+url+":3333/completeOrder", 
        data: ac,
        dataType:"json",
        async:false,
        cache:false,
        timeout:10,
        success: function(data){
            console.log(data);
        },
        error: function(data){
            console.log(data);
        }
    });
    });
</script>
</body>
</html>